package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.entity.Mycoupon;
import com.example.mapper.MycouponMapper;
import com.example.service.IMycouponService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 爪哇岛主
 * @since 2024-07-03
 */
@Service
public class MycouponServiceImpl extends ServiceImpl<MycouponMapper, Mycoupon> implements IMycouponService {

    @Autowired
    private MycouponMapper mycouponMapper;



    @Override
    public List<Mycoupon> searchCoupons(String query) {
        int i = Integer.parseInt(query);
        return baseMapper.searchCoupons(i);
    }




    @Override
    public int countTotalCoupons() {
        return mycouponMapper.countTotalCoupons();
    }




    public List<Mycoupon> getCouponsPaged(int pageNum, int pageSize) {
        Page<Mycoupon> page = new Page<>(pageNum, pageSize);
        return mycouponMapper.selectCouponsPaged(page);
    }






}
